<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'batchEstate.label', default: 'BatchEstate')}"/>
    <title>批次评估管理</title>
</head>

<body>
<div class="small-header transition animated fadeIn">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>CINDATA PLS</li>
                    <li>
                        批次管理
                    </li>
                    <li class="active">
                        <span>批次评估</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                批次评估
            </h2>
        </div>
    </div>
</div>

<g:if test="${params?.message}">
    <div class="message alert alert-info" role="status">${params?.message}</div>
</g:if>

<g:if test="${flash.message}">
    <div class="message alert alert-info" role="status">${flash.message}</div>
</g:if>

<div class="content animate-panel">
    <div class="row">
        <div class="hpanel hgreen contact-panel">
            <div class="panel-heading">
                <div class="panel-tools">
                    <g:link class="btn btn-info btn-xs" action="estateImportBatchEdit" resource="${this.estateImportBatch}"><i class="fa fa-edit"></i>编辑</g:link>
                    <g:link class="btn btn-success btn-xs" action="estateBatchReValuation" id="${this?.estateImportBatch?.id}"><i class="fa fa-edit"></i>执行</g:link>
                </div>
                批次评估基本信息
            </div>

            <div class="panel-body">
                <div class="text-muted font-bold m-b-xs ol-md-6">
                    <div class="col-md-12">
                        <h4>
                            批次评估 ${this.estateImportBatch?.batchNumber}
                        </h4>
                    </div>
                </div>
            </div>

            <div class="panel-footer contact-footer">
                <div class="row">

                    <div class="col-md-3 border-right">
                        <div class="contact-stat">
                            <span>类型</span>
                            <strong>${this.estateImportBatch?.type}</strong>
                        </div>
                    </div>

                    <div class="col-md-3 border-right">
                        <div class="contact-stat">
                            <span>状态</span>
                            <strong>${this.estateImportBatch?.status?.name}</strong>
                        </div>
                    </div>

                    <div class="col-md-3 border-right">
                        <div class="contact-stat">
                            <span>方式</span>
                            <strong>${this.estateImportBatch?.evaluateType?.name}</strong>
                        </div>
                    </div>

                    <div class="col-md-3 border-right">

                        <div class="contact-stat">
                            <span>分发策略</span>
                            <strong>${this.estateImportBatch?.distributeRule?.name}</strong>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="hpanel hred">
            <div class="panel-heading">
                <div class="panel-tools">
                </div>
                评估押品
            </div>
 
            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <g:sortableColumn property="id" title="押品编号"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="evaluateStatue.name" title="评估状态"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="estateStatus.name" title="押品状态"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="cityName" title="城市"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="districtName" title="行政区"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="address" title="地址"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="buildArea" title="面积(平米)"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="totalFloor" title="总楼层"  class="text-center"params="${params}"/>
                            <g:sortableColumn property="currentFloor" title="当前层"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="modifiedDate" title="最新登记日期"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="totalPrice" title="最新评估价值"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="latestEvaluateDate" title="最新评估日期"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="latestEvaluateAccount" title="最新评估机构"  class="text-center" params="${params}"/>
                        </thead>
                        <tbody>
                            <g:each in="${batchEstateList}">
                                <tr class="text-center">
                                    <td><g:link controller="estate" action="show" id="${com.cindata.Collateral.findByEstate(it?.estate)?.id}">${it?.estate?.externalId}</g:link></td>
                                    <td>${it?.evaluateStatue?.name}</td>
                                    <td>${it?.estate?.estateStatus?.name}</td>
                                    <td>${it?.estate?.city?.name}</td>
                                    <td>${it?.estate?.district?.name}</td>
                                    <td>${it?.estate?.sourceAddress}</td>
                                    <td>${it?.estate?.buildArea}</td>
                                    <td>${it?.estate?.sourceTotalFloor}</td>
                                    <td>${it?.estate?.sourceCurrentFloor}</td>
                                    <td><g:formatDate date="${it?.estate?.modifiedDate}" format="yyyy-MM-dd "></g:formatDate></td>
                                    <td>${it?.estate?.totalPrice?it?.estate?.totalPrice:'-'}</td>
                                    <td><g:if test="${it?.estate?.latestEvaluateDate}"><g:formatDate date="${it?.estate?.latestEvaluateDate}" format="yyyy-MM-dd "></g:formatDate></g:if><g:else>-</g:else></td>
                                    <td>${it?.latestEvaluateAccount ? it?.latestEvaluateAccount: '-'}</td>
                                </tr>
                            </g:each>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate total="${batchEstateCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="hpanel hviolet">
            <div class="panel-heading">
                <div class="panel-tools">
                    <g:link class="btn btn-info btn-xs" controller="batchAccount" action="create" params="[batch: this.estateImportBatch.id]">
                        <i class="fa fa-plus"></i>新增
                    </g:link>
                </div>
                评估机构
            </div>

            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <g:sortableColumn property="name" title="机构名称"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="city" title="城市"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="district" title="行政区"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="contact" title="机构联系人"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="phone" title="机构联系方式"  class="text-center" params="${params}"/>
                            <g:sortableColumn width="10%" property="operation" class="text-center" title="操作"/>
                        </tr>
                        </thead>
                        <tbody>
                            <g:each in="${com.cindata.BatchAccount.findAllByBatch(this?.estateImportBatch)}">
                                <tr class="text-center">
                                    <td>${it?.account?.name}</td>
                                    <td>${it?.account?.city?.name}</td>
                                    <td>${it?.account?.district?.name}</td>
                                    <td>${it?.account?.contact}</td>
                                    <td>${it?.account?.phone}</td>
                                    <td width="10%" class="text-center">
                                        <g:form controller="batchAccount" action="delete" id="${it.id}" style="display: inline-block" method="DELETE">
                                            <button class="deleteBtn btn btn-danger btn-xs btn-outline" type="button">
                                                <i class="fa fa-trash-o"></i>删除
                                            </button>
                                        </g:form>
                                    </td>
                                </tr>
                            </g:each>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="hpanel hblue">
            <div class="panel-heading">
                <div class="panel-tools">
                <g:link class="btn btn-info btn-xs" action="estateImportBatchEdit" resource="${this.estateImportBatch}"><i class="fa fa-edit"></i>编辑</g:link>
                </div>
                评估分发策略
            </div>

            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <g:sortableColumn property="name" title="名称"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="city" title="描述"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="city" title="是否有效"  class="text-center" params="${params}"/>
                            <g:sortableColumn property="script" title="内容"  class="text-center" params="${params}"/>
                        </tr>
                        </thead>
                        <tbody>
                            <g:if test="${estateImportBatch?.distributeRule}">
                                <tr class="text-center">
                                    <td>${estateImportBatch?.distributeRule?.name}</td>
                                    <td>${estateImportBatch?.distributeRule?.message}</td>
                                    <td>${estateImportBatch?.distributeRule?.active}</td>
                                    <td width="20%">${estateImportBatch?.distributeRule?.script}</td>
                                </tr>
                            </g:if>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
</html>
